home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / win / tclWinMtherr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  1.4 KB  |  62 lines  |  [TEXT/CWIE]

  1. /* 
  2.  * tclWinMtherr.c --
  3.  *
  4.  *    This function provides a default implementation of the
  5.  *    _matherr function for Borland C++.
  6.  *
  7.  * Copyright (c) 1995 Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tclWinMtherr.c 1.2 96/02/15 11:54:05
  13.  */
  14.  
  15. #include "tclInt.h"
  16. #include "tclPort.h"
  17. #include <math.h>
  18.  
  19. /*
  20.  * The following variable is secretly shared with Tcl so we can
  21.  * tell if expression evaluation is in progress.  If not, matherr
  22.  * just emulates the default behavior, which includes printing
  23.  * a message.
  24.  */
  25.  
  26. extern int tcl_MathInProgress;
  27.  
  28. /*
  29.  *----------------------------------------------------------------------
  30.  *
  31.  * _matherr --
  32.  *
  33.  *    This procedure is invoked by Borland C++ when certain
  34.  *    errors occur in mathematical functions.  This procedure
  35.  *    replaces the default implementation which generates pop-up
  36.  *    warnings.
  37.  *
  38.  * Results:
  39.  *    Returns 1 to indicate that we've handled the error
  40.  *    locally.
  41.  *
  42.  * Side effects:
  43.  *    Sets errno based on what's in xPtr.
  44.  *
  45.  *----------------------------------------------------------------------
  46.  */
  47.  
  48. int
  49. _matherr(xPtr)
  50.     struct exception *xPtr;    /* Describes error that occurred. */
  51. {
  52.     if (!tcl_MathInProgress) {
  53.     return 0;
  54.     }
  55.     if ((xPtr->type == DOMAIN) || (xPtr->type == SING)) {
  56.     errno = EDOM;
  57.     } else {
  58.     errno = ERANGE;
  59.     }
  60.     return 1;
  61. }
  62.